# In our example, we draw some text in Azbuka. The text is vertically and horizontally aligned.

import sys
from PySide import QtGui, QtCore

class Window(QtGui.QWidget):
    def __init__(self):
        super(Window, self).__init__()

        self.text = self.text = u'\u041b\u0435\u0432 \u041d\u0438\u043a\u043e\u043b\u0430\
\u0435\u0432\u0438\u0447 \u0422\u043e\u043b\u0441\u0442\u043e\u0439: \n\
\u0410\u043d\u043d\u0430 \u041a\u0430\u0440\u0435\u043d\u0438\u043d\u0430'

    # Drawing is done within a paintEvent
    def paintEvent(self, event):
        # QtGui.QPainter class is responsible for all the low level painting. All the painting event go between begin()
        # and the end() methods. The actual painting in this program is delegated to the 'drawText' method
        painter = QtGui.QPainter()
        painter.begin(self)
        self.drawText(event, painter)
        painter.end()

    # In the draw text method, we define the pen and font which we use to draw text.
    # The rect() method of the paint event returns the rectangle that needs to be updated.
    def drawText(self, event, painter):
        painter.setPen(QtGui.QColor(168, 34, 3))
        painter.setFont(QtGui.QFont("Decorative", 10))
        painter.drawText(event.rect(), QtCore.Qt.AlignCenter, self.text)

        self.setGeometry(200, 200, 300, 200)
        self.setWindowTitle("Drawing-Text")


if __name__ == "__main__":
    appObject = QtGui.QApplication(sys.argv)
    ex = Window()
    ex.show()
    sys.exit(appObject.exec_())
